A computer file can include a variety of data. For example, a file created by a word processing program such as Microsoft® Word can include formatted text and embedded objects such as pictures. In addition, the file can include metadata, or data relating to attributes of the file itself. The file can include other types of data as well. The file can be saved to a recordable storage medium in a variety of formats. One example format includes a non-binary format, such as plain text. Another example format includes a binary format that is typically compressed and/or structured in a way that is easy for a program to read.
One example binary format is the .ZIP file format (sometimes referred to herein as an “archive file”). Within an archive file, a plurality of archive items can be saved. Each archive item is generally defined by a header and is followed by the contents for the item. The archive items are saved as contiguous blocks within the archive file.
For example, an archive file including three archive items A, B, and C can look as follows:
Item AItem BItem CIn the example shown, item A of the archive file is metadata associated with the file, item B is text associated with the file, and item C is an embedded object such as a picture associated with the file.
When it is necessary to modify the contents of a particular archive item in an archive file, such as archive item A above, the archive item can change in size (i.e., grow or shrink). When archive item A grows or shrinks in size, it is necessary to rewrite the contents of following items B and C because of the contiguous nature of the archive file format. Further, because an archive file can sometimes be written in a compressed format, changes in the contents of the file can cause the file to grow or shrink in unpredictable ways.
For example, if item A increases in size, items B and C need to be shifted to accommodate the change in size of item A, as shown below:
Original:Modified:Item AItem AItem BItem CItem BItem CRewriting all of items that following an item in an archive that is changed can be costly both in terms of performance and the resources used to rewrite the archive items.
It is therefore desirable to provide systems and methods that can efficiently change items in a file.